from .models import Areas
from rest_framework import serializers


class AreasSerializers(serializers.ModelSerializer):
    """
    行政区划列表的序列化器
    """

    class Meta:
        model = Areas

        fields = ["id", "name"]


class AreaSerializers(serializers.ModelSerializer):
    # 关联AreasSerializers查询儿子集字段
    subs = AreasSerializers(many=True)

    class Meta:
        model = Areas
        fields = ["id", "name", "subs"]
